package com.motu.monstercity.server.game.logic;

import com.motu.monstercity.server.game.userdata.*;
import com.motu.vertx.module.utility.model.EntityManager;
import com.motu.vertx.module.utility.model.Model;

import java.util.ArrayList;
import java.util.List;

public class IapUserData extends IapBaseData {

    public static UserIapGift getUserIapGift(long userId, int iapGiftId) {
        return (UserIapGift) EntityManager.getEntity(UserIapGift.class, userId, iapGiftId);
    }

    public static List<UserIapGift> getUserIapGiftList(long userId) {
        List<Model> list = EntityManager.getEntityList(UserIapGift.class, userId);
        List<UserIapGift> reclist = new ArrayList<>();
        for (Model model : list) {
            reclist.add((UserIapGift) model);
        }
        return reclist;
    }

    public static List<IapRecord> getIapRecordList(long userId) {
        List<Model> list = EntityManager.getEntityList(IapRecord.class, userId);
        List<IapRecord> reclist = new ArrayList<>();
        for (Model model : list) {
            reclist.add((IapRecord) model);
        }
        return reclist;
    }

    /**
     * 获取玩家的充值记录列表
     */
    public static List<IapRecord> getIapRecordList(UserInfo userinfo) {
        return getIapRecordList(userinfo.getId());
    }

    // 获取userGrowthFund列表
    public static List<UserGrowthFund> getUserGrowthFundList(long userId) {
        List<UserGrowthFund> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserGrowthFund.class, userId)) {
            UserGrowthFund entity = (UserGrowthFund) model;
            list.add(entity);
        }
        return list;
    }

    public static UserGrowthFund getUserGrowthFund(long userId, int type) {
        return (UserGrowthFund) EntityManager.getEntity(UserGrowthFund.class, userId, type);
    }

    public static List<UserPrivilegeCard> getUserPrivilegeCardList(long userId) {
        List<UserPrivilegeCard> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserPrivilegeCard.class, userId)) {
            UserPrivilegeCard entity = (UserPrivilegeCard) model;
            list.add(entity);
        }
        return list;
    }

    public static UserPrivilegeCard getUserPrivilegeCard(long userId, int type) {
        return (UserPrivilegeCard) EntityManager.getEntity(UserPrivilegeCard.class, userId, type);
    }
}
